#ifndef __MY_DEFINES_H__
#define __MY_DEFINES_H__

#include <stdint.h>
#include <string.h>

//////////////////////////////////////////////////////////////////////////
//
#ifdef WIN32
#define OS_WIN
#else
#define OS_LINUX
#endif // WIN32

//////////////////////////////////////////////////////////////////////////
//
#define tmax(a, b)			((a) < (b) ? (b) : (a))
#define tmin(a, b)			((a) > (b) ? (b) : (a))
#define tabs(a)				((a) < 0 ? -(a) : (a))
#define is_odd(a)			((a) & 1)
#define climb(a, low, high)	tmax(low, tmin(high, a))
#define adjust4(a)			(((a) + 3) >> 2 << 2)
#define qby2(a)				((a) << 1)
#define qby4(a)				((a) << 2)
#define qby3(a)				(qby2(a) + a)
#define bzero(p, len)		memset(p, 0, len)

#define ARRAY_SIZE(a)		(sizeof(a) / sizeof(*a))
#define SAFE_DEL_PTR(p)		if (p) { delete p; p = NULL; }
#define SAFE_DELETE_ARR(p)	if (p) { delete[] p; p = NULL; }
#define SAFE_FREE(p)		if (p) { free(p); p = NULL; }
#define SAFE_FCLOSE(f)		if (f) { fclose(f); f = NULL; }

#endif // __MY_DEFINES_H__
